
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class Comment {
	
	function get_all_comment(){
		
		$CI =& get_instance();
		$CI->load->model('md_common'); 
		$comments= $CI->md_common->query("select  a.*,b.username,b.user_id from `comment` a inner join `user` b on  a.user_id = b.user_id");
		$arr_ret = array(); 
		
		foreach ($comments as $item){
			$arr_comm = array('comment' => $item);
			$comment_id = $item->id;
			//get comments detail
			$comment_detail = $CI->md_common->query("select  a.*,b.username,b.user_id from `comment_detail` a inner join `user` b on  a.user_id = b.user_id where a.comment_id = $comment_id");
			$arr_comm['comment_detail'] = $comment_detail;
			
			array_push($arr_ret,$arr_comm);
		}
		return  $arr_ret;
	}
	
} 
?>